home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / siv / s3.asm < prev    next >
Assembly Source File  |  1994-04-25  |  13KB  |  413 lines

  1. ; First Attempt at scrolling...
  2. ────────────────────────────────────────────────────────────────────────────────
  3.  
  4.  
  5.         .model small
  6.         .286
  7.         .stack 1024
  8.         .data
  9.         jumps
  10.  
  11.                ;                  1                   2                   3
  12.                ;1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 6
  13. map1    db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;0
  14.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;1
  15.         db      1,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;2
  16.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;3
  17.         db      0,1,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;4
  18.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;5
  19.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;6
  20.         db      0,0,1,1,0,0,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0 ;7
  21.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;8
  22.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;9
  23.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;0
  24.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;1
  25.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;2
  26.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;1
  27.         db      1,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;2
  28.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;3
  29.         db      0,1,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;4
  30.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;5
  31.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;6
  32.         db      0,0,1,1,0,0,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0 ;7
  33.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;8
  34.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;9
  35.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;0
  36.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;1
  37.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;2
  38.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;1
  39.         db      1,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;2
  40.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;3
  41.         db      0,1,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;4
  42.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;5
  43.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;6
  44.         db      0,0,1,1,0,0,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0 ;7
  45.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;8
  46.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;9
  47.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;0
  48.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;1
  49.         db      0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0 ;2
  50.  
  51.  
  52. rows    dw      0
  53.     @@i=0
  54.     REPT    200
  55.     @@i=@@i+320
  56.     dw    @@i
  57.     ENDM
  58.  
  59. blocks  db      1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6  ;1
  60.         db      1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6  ;2
  61.         db      1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6  ;3
  62.         db      1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6  ;4
  63.         db      1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6  ;5
  64.         db      1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6  ;6
  65.         db      1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6  ;7
  66.         db      1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6  ;8
  67.         db      1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6  ;9
  68.         db      1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6  ;0
  69.         db      1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6  ;1
  70.         db      1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6  ;2
  71.         db      1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6  ;3
  72.         db      1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6  ;4
  73.         db      1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6  ;5
  74.         db      1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6  ;6
  75.  
  76.         db      10,2,3,4,5,6,7,8,9,0,1,2,3,4,5,60  ;0
  77.         db      10,2,3,4,5,6,7,8,9,0,1,2,3,4,50,6  ;1
  78.         db      10,2,3,4,5,6,7,8,9,0,1,2,3,40,5,6  ;2
  79.         db      10,2,3,4,5,6,7,8,9,0,1,2,30,4,5,6  ;3
  80.         db      10,2,3,4,5,6,7,8,9,0,1,20,3,4,5,6  ;4
  81.         db      10,2,3,4,5,6,7,8,9,0,10,2,3,4,5,6  ;5
  82.         db      10,2,3,4,5,6,7,8,9,00,1,2,3,4,5,6  ;6
  83.         db      10,2,3,4,5,6,7,8,90,0,1,2,3,4,5,6  ;7
  84.         db      10,2,3,4,5,6,7,80,9,0,1,2,3,4,5,6  ;8
  85.         db      10,2,3,4,5,6,70,8,9,0,1,2,3,4,5,6  ;9
  86.         db      10,2,3,4,5,60,7,8,9,0,1,2,3,4,5,6  ;0
  87.         db      10,2,3,4,50,6,7,8,9,0,1,2,3,4,5,6  ;1
  88.         db      10,2,3,40,5,6,7,8,9,0,1,2,3,4,5,6  ;2
  89.         db      10,2,30,4,5,6,7,8,9,0,1,2,3,4,5,6  ;3
  90.         db      10,20,3,4,5,6,7,8,9,0,1,2,3,4,5,6  ;4
  91.         db      10,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6  ;5
  92.  
  93.         db      1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6
  94.  
  95. palette1        db      768     dup     (?)
  96. main1_pic       db      'main1.pic',0
  97. fileh           dw      0
  98.  
  99. ;--- The offset of the current map
  100. mapoff          dw      offset map1
  101. ;--- The dimensions of the current map
  102. mapx            dw      36
  103. mapy            dw      36
  104. maxxpos         dw      23*16
  105. minxpos     dw    0
  106. maxypos         dw      12*16
  107. minypos         dw      0
  108.  
  109. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄Scroll1▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  110. ;--- These all get calculated anyway.
  111. indexX          dw      0
  112. indexY          dw      0
  113. ;--- These are required as starting position
  114. Ypos            dw      100
  115. Xpos            dw      100
  116. ;--- Set these for each scroll...
  117. movex           dw      2
  118. movey           dw      -2
  119. ;--- These are the pointers...
  120. scrorigin       dw      0
  121. source          dw      0
  122.  
  123. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄Scroll2▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  124. ;--- These all get calculated anyway.
  125. indexX2         dw      0
  126. indexY2         dw      0
  127. ;--- These are required as starting position
  128. Ypos2           dw      100
  129. Xpos2           dw      50
  130. ;--- Set these for each scroll...
  131. movex2          dw      1
  132. movey2          dw      1
  133. ;--- These are the pointers...
  134. scrorigin2      dw      0
  135. source2         dw      0
  136.  
  137.  
  138. ;------- segments: ---------
  139. background      dw      0
  140. background2     dw      0
  141.  
  142.  
  143. ────────────────────────────────────────────────────────────────────────────────
  144. ;       The code segment...
  145.  
  146.         .code
  147.  
  148. Main:
  149.         mov     ah,04ah
  150.         mov     bx,10000/16
  151.         int     21h
  152.  
  153.         mov     dx,@data
  154.         mov     ds,dx
  155.  
  156.         mov     ah,048h
  157.         mov     bx,1000h
  158.         int     21h
  159.         jc      nosav
  160.         mov     background,ax
  161.  
  162.         mov     ah,048h
  163.         mov     bx,1000h
  164.         int     21h
  165.         jc      nosav
  166.         mov     background2,ax
  167.  
  168.         mov     ax,13h
  169.         int     10h
  170.         mov     ax,0a000h
  171.         mov     es,ax
  172.         ; graphix is up, background is up
  173.  
  174.         mov     ax,3d00h
  175.         mov     dx,offset main1_pic
  176.         int     21h
  177.         jc      nosav
  178.  
  179.         mov     fileh,ax
  180.         mov     bx,ax
  181.         mov     ah,42h
  182.         xor     al,al
  183.         xor     cx,cx
  184.         mov     dx,32
  185.         int     21h
  186.         jc      nosav
  187.  
  188.         mov     bx,fileh
  189.         mov     ah,3fh
  190.         mov     cx,768
  191.         mov     dx,offset palette1
  192.         int     21h
  193.         jc      nosav
  194.  
  195.         mov     bx,fileh
  196.         mov     ah,3fh
  197.         mov     cx,64000
  198.         push    ds
  199.         mov     dx,0a000h
  200.         mov     ds,dx
  201.         xor     dx,dx
  202.         int     21h
  203.         jc      nosav
  204.         pop     ds
  205.  
  206.         mov     ah,3eh
  207.         int     21h
  208.         jc      nosav
  209.  
  210.         mov     dx,3c8h
  211.         xor     al,al
  212.         out     dx,al
  213.         inc     dx
  214.         mov     cx,768
  215.         mov     si,offset palette1
  216.         rep     outsb
  217.  
  218. ;        xor     di,di
  219.         call    initscroll1
  220.         mov     di,scrorigin
  221.         sub     di,16+16*320
  222.         mov     si,offset map1
  223.         push    es
  224.         mov     cx,background
  225.         mov     es,cx
  226.         mov     cx,10
  227. ll1:
  228.         push    di
  229.         push    cx
  230.         mov     cx,10
  231.         push    si
  232. ll2:    lodsb
  233.         push    di
  234.         push    cx
  235.         call    do16fs
  236.         pop     cx
  237.         pop     di
  238.         add     di,16
  239.         loop    ll2
  240.         pop     si
  241.         add     si,mapx
  242.         pop     cx
  243.         pop     di
  244.         add     di,16*320
  245.         loop    ll1
  246.         pop     es
  247.  
  248.         mov     cx,mapx
  249.         sub     cx,8
  250.         shl     cx,4
  251.         mov     maxxpos,cx
  252.  
  253.         mov     bx,Ypos
  254.         shl     bx,1
  255.         mov     di,rows[bx]
  256.         add     di,Xpos
  257.         mov     SCRorigin,di
  258.         mov     bx,Xpos
  259.         and     bx,15
  260.         mov     indexX,bx
  261.         mov     bx,Ypos
  262.         and     bx,15
  263.         mov     indexY,bx
  264.  
  265.         mov     bx, Ypos
  266.         shr     bx, 4
  267.         mov     ax, mapX
  268.         mul     bx
  269.         mov     source, ax
  270.         mov     bx, Xpos
  271.         shr     bx, 4
  272.         add     source, bx
  273.  
  274.         call    init_scroll2
  275.  
  276. ;
  277. ; ▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄
  278. ;█  ┌─┬─┐ ┌───┐ ┐ ┌──┐    │     ┌───┐ ┌───┐ ┌───┐  █
  279. ;█  │   │ │   │ │ │  └┐   │     │   │ │   │ │   │  █
  280. ;█  │   │ ├───┤ │ │   │   │     │   │ │   │ ├───┘  █
  281. ;█  │   │ │   │ │ │   │   └───  └───┘ └───┘ │      █
  282. ; ▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀
  283. ;
  284. mainl1:
  285.         mov     cx,background
  286.         mov     di,16+14*320
  287.         mov     si,scrorigin
  288.         call    transfer_scroll          ;transfer the data to the screen
  289.  
  290.         mov     cx,background2
  291.         mov     di,176+14*320
  292.         mov     si,scrorigin2
  293.         call    transfer_scroll          ;transfer the data to the screen
  294.  
  295.         call    update_scroll1
  296.         call    update_scroll2
  297.  
  298.         call    check2
  299.         call    check1
  300.  
  301.         mov     ah,1
  302.         int     16h
  303.         jnz     nosav
  304.         call    waitretrace
  305.         jmp     mainl1
  306. nosav:
  307.         mov     ax,04c00h
  308.         int     21h
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322. write_block:
  323. writeblock:
  324. do16fs: ; writes a 16x16 block to es:di (now 286...) from ds:si
  325.         mov     cx,16
  326. do16fs1:
  327.         push    cx
  328.         mov     cx,16
  329.         rep     movsb
  330.         pop     cx
  331.         add     di,320-16
  332.         loop    do16fs1
  333.         ret
  334.  
  335. transfer_scroll: ; writes a 16x16 from fs:si to es:di
  336. transferscroll:  ; cx is the segment...
  337.                  ; es is the destination segment
  338.                  ; di is the destination pointer
  339.                  ; si is the source pointer
  340.         push    ds
  341.         mov     ds,cx
  342.         mov     cx,8*16
  343. do16es1:
  344.         push    cx
  345.         mov     cx,8*16
  346.         rep     movsb
  347.         pop     cx
  348.         add     si,320-128
  349.         add     di,320-128
  350.         loop    do16es1
  351.         pop     ds
  352.         ret
  353.  
  354. include ret.inc
  355.  
  356.  
  357. do_row:
  358.         ; di is the position in backmem
  359.         ; si is the position in map...
  360.         ; cx is the segment
  361.         push    es
  362.         mov     es,cx
  363.         mov     cx,9    ; 8 tiles across, one extra incase of x warp.
  364. dorow1:
  365.         push    cx
  366.         lodsb
  367.         push    si
  368.         mov     ah,al
  369.         xor     al,al
  370.         mov     si,ax
  371.         add     si,offset blocks
  372.         push    di
  373.  
  374.         call    do16fs
  375.  
  376.         pop     di
  377.         add     di,16
  378.         pop     si
  379.         pop     cx
  380.         loop    dorow1
  381.         pop     es
  382.         nop
  383.         ret
  384.  
  385. do_col:
  386.     ; di is the position in backmem
  387.     ; si is the position in map....
  388.         ; cx is the segment
  389.         push    es
  390.         mov     es,cx
  391.         mov     cx,9
  392. docol1:
  393.         mov     ah, [si]
  394.         push    si
  395.         xor     al,al
  396.         mov     si,ax
  397.         add     si,offset blocks
  398.         push    cx
  399.         push    di
  400.         call    do16fs
  401.         pop     di
  402.         pop     cx
  403.         pop     si
  404.     add    si, mapx
  405.     add    di, 16*320
  406.     loop    docol1
  407.         pop     es
  408.     ret
  409. include scroll2.inc
  410. include scroll1.inc
  411.  
  412. END Main
  413.